library("cellHTS2")
experimentName <- "VWF_1_PercentWPBarea"

# Set work dir
setwd("/media/home01_2010/home/kvjanos/VWF/Opera_vWF_3_R_Python_cellHTS2_Results/2_R_cellHTS2/1_PercentWPBarea/1_PercentWPBarea_cellHTS2_SciData/")
dataPath <- c("/media/home01_2010/home/kvjanos/VWF/Opera_vWF_3_R_Python_cellHTS2_Results/2_R_cellHTS2/1_PercentWPBarea/1_PercentWPBarea_cellHTS2_SciData")

# Open data files
x <- readPlateList("Platelist.txt", name=experimentName, path=dataPath) 

x <- configure(x,
                descripFile="Description.txt", 
                confFile="Plateconf.txt", 
                path=dataPath)

table(wellAnno(x))
configurationAsScreenPlot(x)

# Normalization
xn <- normalizePlates(x, 
                       scale="multiplicative", 
                       log=FALSE, 
                       method="Bscore", 
                       varianceAdjust="none")

# Standardize the values for each replicate
xsc <- scoreReplicates(xn, sign="-", method="zscore")

# Scoring
xsc <- summarizeReplicates(xsc, summary="mean")

# Annotation
xsc <- annotate(xsc, geneIDFile="Human_Kinase_Panel_plates1-11.txt", path=dataPath)

# Boxplots of the z-scores 
scores <- Data(xsc)
ylim <- quantile(scores, c(0.001, 0.999), na.rm=TRUE)
boxplot(scores ~ wellAnno(x), col="lightblue", outline=FALSE, ylim=ylim)
dev2bitmap("/media/home01_2010/home/kvjanos/VWF/Opera_vWF_3_R_Python_cellHTS2_Results/2_R_cellHTS2/1_PercentWPBarea/1_PercentWPBarea_cellHTS2_SciData/VWF_1_PercentWPBarea_ZscoresBoxplot.png", res = 600)

xsc

# Save scored data set
save(xsc, file=paste(experimentName, ".rda", sep=""))

setSettings(list(plateList=list(reproducibility=list(include=TRUE, map=TRUE), 
                  intensities=list(include=TRUE, map=TRUE)),
                  screenSummary=list(scores=list(range=c(-4, 8), map=TRUE))))
out <- writeReport(raw=x, normalized=xn, scored=xsc, map=TRUE, force=TRUE, outdir="report-VWF_1_PercentWPBarea", mainScriptFile="cellHTS2_VWF_1_PercentWPBarea.R")


# sessionInfo()
# R version 3.2.5 (2016-04-14)
# Platform: x86_64-pc-linux-gnu (64-bit)
# Running under: Ubuntu precise (12.04.5 LTS)
# 
# locale:
#  [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C              
#  [3] LC_TIME=en_GB.UTF-8        LC_COLLATE=en_GB.UTF-8    
#  [5] LC_MONETARY=en_GB.UTF-8    LC_MESSAGES=en_GB.UTF-8   
#  [7] LC_PAPER=en_GB.UTF-8       LC_NAME=C                 
#  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
# [11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C       
# 
# attached base packages:
# [1] grid      parallel  stats     graphics  grDevices utils     datasets 
# [8] methods   base     
# 
# other attached packages:
# [1] cellHTS2_2.30.0     locfit_1.5-9.1      hwriter_1.3.2      
# [4] vsn_3.34.0          splots_1.32.0       genefilter_1.48.1  
# [7] Biobase_2.26.0      BiocGenerics_0.12.1 RColorBrewer_1.1-2 
# 
# loaded via a namespace (and not attached):
#  [1] pcaPP_1.9-60          prada_1.42.0          BiocInstaller_1.16.5 
#  [4] DEoptimR_1.0-4        GenomeInfoDb_1.2.5    tools_3.2.5          
#  [7] zlibbioc_1.12.0       annotate_1.44.0       RSQLite_1.0.0        
# [10] preprocessCore_1.28.0 lattice_0.20-33       Matrix_1.2-3         
# [13] graph_1.44.1          DBI_0.3.1             Category_2.32.0      
# [16] mvtnorm_1.0-5         cluster_2.0.3         S4Vectors_0.4.0      
# [19] IRanges_2.0.1         stats4_3.2.5          robustbase_0.92-5    
# [22] GSEABase_1.28.0       rrcov_1.3-8           AnnotationDbi_1.28.2 
# [25] XML_3.98-1.3          survival_2.38-3       RBGL_1.42.0          
# [28] limma_3.22.7          splines_3.2.5         MASS_7.3-45          
# [31] xtable_1.8-2          affy_1.44.0           affyio_1.34.0   